Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds spec for yield in singleton class #801

Merged
merged 2 commits into from
Oct 18, 2020

Conversation

moofkit
Copy link
Contributor

@moofkit moofkit commented Oct 17, 2020

Solving #745

yield in singleton class syntax is warned and will be deprecated later. Feature #15575.

def foo
  class << Object.new
    yield #=> warning: `yield' in class syntax will not be supported from Ruby 3.0. [Feature #15575](https://bugs.ruby-lang.org/issues/15575)
  end
end
foo { p :ok }

I was trying different approaches to catch the warning. evaluates block does not fit there because warning emits on parsing stage.
Maybe it will be better to using eval here?

@andrykonchin
Copy link
Member

andrykonchin commented Oct 17, 2020

Yeah, eval would be much better. At least faster as far as ruby_exe starts new process. It's a common practice to use eval in order to catch error/warning on parsing step.

@moofkit
Copy link
Contributor Author

moofkit commented Oct 18, 2020

@andrykonchin thanks! I've just fix that

@andrykonchin
Copy link
Member

Thank you 👍 .

@andrykonchin andrykonchin merged commit 01d0d99 into ruby:master Oct 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants